const http = require("http");
const url = require("url");

const server = http.createServer((req, res) => {
  console.log("请求头", req.httpVersion, req.url, req.method);
  console.log(
    "url携带参数",
    url.parse(req.url, true).query,
    url.parse(req.url, true).pathname
  );

  console.log("请求头", req.headers);

  // 请求体
  let chunk = [];
  req.on("data", (data) => {
    chunk.push(data);
  });

  req.on("end", () => {
    let body = Buffer.concat(chunk).toString();
    console.log(body);
  });

  res.end("finish");
});

server.listen(1234, () => {
  console.log("server is running");
});
